﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AuroraWuBi
{
   public class Word
    {
        private Dictionary<string, List<string>> _WordDit;//所有字、词
        private List<string> _JM_1;//一级简码
        private List<string> _JM_2;//二级简码
        private List<string> _JM_3;//三级简码


        public Dictionary<string, List<string>> WordDit
        {
            get
            {
                return _WordDit;
            }
        }

        public List<string> JM_1
        {
            get
            {
                return _JM_1;
            }
        }
        public List<string> JM_2
        {
            get
            {
                return _JM_2;
            }
        }
        public List<string> JM_3
        {
            get
            {
                return _JM_3;
            }
        }
        public void AddWord(string word, string code)
        {
            if (word == null | code == null)
                return;
            if (_WordDit == null)
            {
                _WordDit = new Dictionary<string, List<string>>();
                _WordDit.Add(word, new List<string> { code });
            }
            else
            {
                if (_WordDit.ContainsKey(word))
                {
                    if (!_WordDit[word].Contains(code))
                        _WordDit[word].Add(code);
                }
                else
                {
                    _WordDit.Add(word, new List<string> { code });
                }
            }

            switch (code.Length)
            {
                case 1:
                    if (_JM_1 == null)
                        _JM_1 = new List<string>() { word };
                    else
                        if (!_JM_1.Contains(word))
                        JM_1.Add(word);

                    break;
                case 2:
                    if (_JM_2 == null)
                        _JM_2 = new List<string>() { word };
                    else
                        if (!_JM_2.Contains(word))
                        JM_2.Add(word);
                    break;
                case 3:
                    if (_JM_3 == null)
                        _JM_3 = new List<string>() { word };
                    else
                         if (!_JM_3.Contains(word))
                        JM_3.Add(word);
                    break;
                default:
                    break;
            }

        }
    }
}
